def insertion_sort(arr):
    for i in range(1, len(arr)):
        key = arr[i]
        j = i - 1
        while j >= 0 and arr[j] > key:
            arr[j + 1] = arr[j]
            j -= 1
        arr[j + 1] = key

    return arr

if __name__ == "__main__":
    arr = [15, 11, 18, 9, 2]
    print("排序前的数组:", arr)
    sorted_arr = insertion_sort(arr)
    print("排序后的数组:", sorted_arr)